package com.xmlasia.remote.transformer;

import java.io.ByteArrayOutputStream;
import java.util.zip.GZIPOutputStream;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.integration.transformer.AbstractPayloadTransformer;

public class ByteZipTransformer extends AbstractPayloadTransformer<byte[], byte[]> {

	private final Logger logger = LoggerFactory.getLogger(ByteZipTransformer.class);

	@Override
	protected byte[] transformPayload(byte[] payload) throws Exception {
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
		GZIPOutputStream gos = new GZIPOutputStream(baos);
		gos.write(payload);
		gos.close();
		logger.info("Length :{}", payload.length);
		logger.info("Size :{}", baos.size());
		return baos.toByteArray();
//		logger.info("####");
//		return payload;
	}
	
	 

}
